package com.arr;

public class BinarySearch {

	public int search(int[] a, int key)
	{
		int start = 0;
		int end = a.length -1;
		int mid = end / 2;
		//int test = 1;
		while(start <= end)
		{
			if(key == a[mid])
			return mid;
			else if(key < a[mid])
			{
				end = mid -1;
			}
			else
			{
				start = mid + 1;
			}
			mid = (end + start) / 2;
		}
		return -1;
	}
}
